const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const Webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
const VueLoaderPlugin = require("vue-loader/lib/plugin");

module.exports = {
    entry: "./src/main.js",
    mode:'development',
    devServer: {
        hot: true
    },
    output: {
        filename: "index.[hash:4].js",
        path: path.join(__dirname, "dist")
    },
    module:{
        rules: [
            {
                test: /\.vue$/,
                loader: "vue-loader"
            },
            {
                test: /\.css$/,
                use: [MiniCssExtractPlugin.loader,"css-loader"]
            }
        ]
    },
    plugins :[
        new Webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
                template: "./public/index.html"
            }),
        new MiniCssExtractPlugin({
            filename: "style.css"
        }),
        new CleanWebpackPlugin(),
        new VueLoaderPlugin()
    ]
}